#include <iostream>
#include <string.h>
using namespace std;

class mytime
{
public:
    void settime(int h,int m,int s)
    {
        if((h>=0 && h<24) && (m>=0 && m<60) && (s>=0 && s<60))
        {
            hour = h;
            minute = m;
            second = s;
        }else
        {
            cout << "时间设置错误" << endl;
        }
    }
    void display()
    {
        cout << hour << ":" << minute << ":" << second << endl;
    }
    void nextsecond()
    {
        second++;
        if(second>=60) // 秒数超过60，分钟加1，秒数重置为0
        {
            second = 0;
            minute++;
        }
        if(minute>=60) // 分钟超过60，小时加1，分钟重置为0
        {
            minute = 0;
            hour++;
        }
        if(hour>=24) // 小时超过24，重置为0
        {
            hour = 0;
        }
    }
private:
    int hour;
    int minute;
    int second;
};

int main()
{
    mytime t;
    t.settime(12,59,59);
    t.display();
    t.nextsecond();
    t.display();
    return 0;
}